package jdly.water.api.controller.base;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import jdly.water.api.common.service.R;
import jdly.water.api.model.PageModel;
import jdly.water.api.service.base.BaseService;

@RestController
public class BaseController {

	@Autowired	
	private BaseService baseService;
	
	@GetMapping("/meterlist")
	@ResponseBody
	public R meterlist(String orgname,String floor,String unit,String room,String meternumber,PageModel page) {
		Map<String,Object> param= new HashMap<String,Object>();
		param.put("building.org.orgname", orgname);
		param.put("building.floor", floor);
		param.put("building.unit", unit);
		param.put("building.room", room);
		param.put("meterNumber", meternumber);
		return baseService.userlist(page, param);
	}
	@GetMapping("/meter")
	@ResponseBody
	public R meter(String id) {
		
		return baseService.getMeter(id);
	}
	@PostMapping("/updatemeter")
	@ResponseBody
	public R updatemeter(String meternumber,String id) {
		
		return baseService.updateMeter(meternumber, id);
	}
	
	@GetMapping("/collector")
	@ResponseBody
	public R collector(String id) {
		
		return baseService.getCollector(id);
	}
	
	@PostMapping("/updatecollector")
	@ResponseBody
	public R updatecollector(String tel,String id) {
		
		return baseService.updateCollector(tel, id);
	}
	
	@PostMapping("/updatebm")
	@ResponseBody
	public R updatebm(String meternumber,String id) {
		
		return baseService.updateBm(meternumber, id);
	}
	@GetMapping("/bmeter")
	@ResponseBody
	public R bmeter(String id) {
		
		return baseService.getBm(id);
	}
	
	@GetMapping("/bmlist")
	@ResponseBody
	public R bmlist(String search,PageModel page) {
		
		return baseService.dongbiao(page, search);
	}
	
	@GetMapping("/tmlist")
	@ResponseBody
	public R tmlist(String search,PageModel page) {
		
		return baseService.zongbiao(page, search);
	}
	
	@GetMapping("/dtulist")
	@ResponseBody
	public R dtulist(String search) {
		
		return baseService.dtu(search);
	}
	
	
	
	
	

}
